program tangqiao;

const max=200;

var shu:array[0..max] of integer;
    n,time:integer;

procedure input;  {**** input the information ****}
 begin
   writeln;
   writeln('Input');
   readln(n,time);
 end;

procedure init;
 var i:integer;
 begin
   for i:=1 to n do
      shu[i]:=1;
   shu[0]:=0;
 end;

function check:boolean;
 var k:boolean;
     i,j:integer;
 begin
   j:=0;
   for i:=1 to n do
     if shu[i]=1 then
       inc(j);
   if j<>1 then k:=true
           else k:=false;
   check:=k;
 end;

procedure course;
 var chi,num,i:integer;
 begin

   num:=0;

   while check do
     begin
       chi:=0;
       repeat
         inc(num);
         if num=n+1 then num:=1;
         while shu[num]<>1 do
           begin
             inc(num);
             if num=n+1 then num:=1;
           end;
         inc(chi);
       until chi=time;
       shu[num]:=0;
     end;
 end;

procedure output; {**** output the information ***}
 var i:integer;
 begin
   writeln('Output');
   i:=1;
   while shu[i]<>1 do inc(i);
   writeln('the winner is No.',i);
 end;

begin
  input;

  init;

  course;

  output;
end.
